// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import Axios from "axios"
import qs from "qs"

Vue.prototype.$axios = Axios
Axios.defaults.baseURL = '/api';//其他地方请求地址可以省略域名 
//Axios.defaults.headers.common['Authorization'] = AUTH_TOKEN;//第三方认证涉及到token 如果没有可以干掉
Axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';// 全局设置post请求的数据编码格式


// http request 请求拦截器
Axios.interceptors.request.use(config => {
	config.headers['Content-Type'] = 'application/x-www-form-urlencoded' 
	console.log("请求:"+config)
	// 在发送请求之前做些什么
	if (config.method === "post") {
		qs.stringify(config.data);
	 }
	return config;
}, error => {
	// 对请求错误做些什么
	return Promise.reject(error);
});


// http response 响应拦截器
Axios.interceptors.response.use(response => {
	console.log("响应:"+response)
 	return response;
},error => {
	return Promise.reject(error);
});


Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
